package praktikumid.p02_t;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author ago.luberg
 *
 */
public class InputExample {
	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		String tekst;
		
		String[] tekstid = new String[10];
		// array index
		int count = 0;

		// standard input STDIN
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		
		tekstid[0] = "esimene";
		tekstid[1] = "teine";
		
		
    	while (true) {
			System.out.println("Sisesta tekst:");
			// readLine() throws IOException, we will pass it on
			// ("throws IOException" on method definition line)
			// 2nd option: use try/catch
			tekst = br.readLine();
			
			System.out.println("Sain: " + tekst);
			
			tekstid[count] = tekst;
			count++;
			/*
			 * print tekstid[0]
			 * print tekstid[1]
			 * print tekstid[2]
			 * print tekstid[3]
			 * ..
			 * print tekstid[9]
			 * 
			 */
			int i;
			System.out.println("senised tekstid:");
			for (i = 0; i < count; i++) {
				System.out.println(tekstid[i]);
			}
			
			if (tekst.equalsIgnoreCase("exit")) {
				System.out.println("bye!");
				break;
			}
		}
	}
}